package com.hspedu.StringBuffer;

/**
 * @Author Stringzhua
 * @Date 2024/3/9 18:04
 * description:分析程序输出结果?
 * <p>
 * 4
 * null
 */
public class StringBufferExercise01 {
    public static void main(String[] args) {
        String str = null;
        StringBuffer sb = new StringBuffer();
        sb.append(str);//底层调用的是父类的AbstractStringBulider的appendNull
        System.out.println(sb.length());//4

        System.out.println(sb);//null
        // super(str.length() + 16);
        //下面的构造器会抛出空指针异常
        StringBuffer sb1 = new StringBuffer(str);//null对象 空指针异常NullPointerException
        System.out.println(sb1);
    }
}
